package jianzhiOfferII;

import java.util.HashMap;
import java.util.Map;

//剑指 Offer II 004. 只出现一次的数字
public class Num004_singleNumber {
    public int singleNumber(int[] nums) {
        Map<Integer,Integer> map = new HashMap<>();

        for (int i:nums) {
            map.put(i, map.getOrDefault(i, 0) + 1);

        }
        for (Map.Entry<Integer,Integer> entry :map.entrySet()) {
            int num = entry.getKey();
            int occ = entry.getValue();
            if (occ == 1) {
                return num;

            }


        }


        return 0;

    }

}
